﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Mozlite.Common;

namespace Mozlite.Web.UI.Controllers
{
    public class DialogController : CommonBaseController
    {
        [HttpPost]
        public JsonResult PostView(FormCollection form)
        {
            if (ModelState.IsValid)
            {
                switch (form.GetAction())
                {
                    case HttpAction.Delete:
                        if (Permissions.GetPermission<UCenterPermission>().AllowComments != true)
                            return Json(new { message = GLocal("PermissionDisallowed") });
                        if (Threads.DeletePost(form.Get<int>("postid")))
                            return Json(new { status = true, message = GLocal("Post.Delete.Success") });
                        return Json(new {message = GLocal("Post.Delete.Error") });
                }
            }
            return Json(new { message = GLocal("Error") });
        }
    }
}
